﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using ApartmentBillsManager.Start.Common;

namespace ApartmentBillsManager.Start.Converters
{
    class RelevantRoommatesConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is List<Roommate>)
            {
                string roommatesString = string.Empty;

                foreach (var roommate in (List<Roommate>)value)
                {
                    roommatesString += roommate.Name + ", ";
                }

                roommatesString = roommatesString.TrimEnd(new[] { ',', ' ' });

                if (roommatesString == string.Empty)
                    return "None";

                return roommatesString;
            }

            return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
